package com.bbex.mapper;

import com.bbex.entity.OfflineTransferLog;
import com.bbex.sql.build.OfflineTransferLogSqlBuild;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OfflineTransferLogDao {

    @InsertProvider(type = OfflineTransferLogSqlBuild.class, method = "insert")
    void insert(OfflineTransferLog offlineTransferLog);

    @SelectProvider(type = OfflineTransferLogSqlBuild.class, method = "findById")
    OfflineTransferLog findById(String id);

    @UpdateProvider(type = OfflineTransferLogSqlBuild.class, method = "updateById")
    long updateById(OfflineTransferLog offlineTransferLog);

    @Select("select " + OfflineTransferLogSqlBuild.columns + " from js_plat_offline_transfer_log where user_id = #{userId} and type < 90 order by create_date desc")
    List<OfflineTransferLog> findOfflineTransferLogByUserId(String userId);

    @Select("select " + OfflineTransferLogSqlBuild.columns + " from js_plat_offline_transfer_log where coin_id = #{coinId} and user_id = #{userId} and type < 90 order by create_date desc")
    List<OfflineTransferLog> findOfflineTransferLogByUserIdAndCoinId(@Param("userId") String userId, @Param("coinId") String coinId);

    @Select("select id,user_id as userId,coin_id as coinId,coin_symbol as coinSymbol,volume,fee_volume as feeVolume,type,create_by as createBy," +
            "update_by as updateBy,create_date as createDate,update_date as updateDate " +
            "from js_plat_offline_transfer_log where user_id = #{userId} order by create_date desc")
    List<OfflineTransferLog> findCoinoutPage(String userId);

}
